package com.chzc.vo;

import io.swagger.annotations.ApiModel;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 购物车对象
 *
 * @author cv大魔王
 * @version 1.0
 * @date 2021/6/6 16:29
 */
@ApiModel(value = "购物车对象", description = "购物车对象")
public class CarVo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 购物项
     */
    private List<GoodsItemCarVO> cartItems;

    /**
     * 购物车总价格
     */
    private Double totalAmount;


    /**
     * 总价格
     *
     * @return
     */
    public Double getTotalAmount() {
        BigDecimal sum = new BigDecimal("0");
        for (GoodsItemCarVO cartItem : cartItems) {
            sum = sum.add(BigDecimal.valueOf(cartItem.getTotalPrice()));
        }
        return sum.doubleValue();
    }

    public List<GoodsItemCarVO> getCartItems() {
        return cartItems;
    }

    public void setCartItems(List<GoodsItemCarVO> cartItems) {
        this.cartItems = cartItems;
    }

}
